{% extends "dvaui/base.html" %}
{% load staticfiles %}

{% block page_content %}
<section class="content-header" style="padding-top:0px" xmlns="http://www.w3.org/1999/html">
<div class="row">
    <div class="box box-info">
        <div class="box-header">
            <h2>Inspect, Monitor & Launch processes</h2>
            {% if is_paginated %}
                <div class="pagination text-center" style="width:100%">
                    <span class="page-links">
                        {% if page_obj.has_previous %}
                            <a class="btn btn-info" style="float:left" href=".?page={{ page_obj.previous_page_number }}"><i class="fa fa-backward"></i>  Go back</a>
                        {% endif %}
                        <span class="page-current " style="font-size:24pt;font-weight:bold">
                            {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
                        </span>
                        {% if page_obj.has_next %}
                            <a class="btn btn-info" style="float:right" href=".?page={{ page_obj.next_page_number }}">Load more  <i class="fa fa-forward"></i></a>
                        {% endif %}
                    </span>
                </div>
            {% endif %}
        </div>
    </div>
</div>
</section>
<section class="content">
    <div class="row">
        <div class="col-lg-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h4>Running & Completed processes</h4>
                </div>
                <div class="box-body">
                    <table class="table dataTables">
                    <thead>
                    <tr>
                        <th class="text-center">User</th>
                        <th class="text-center">Type</th>
                        <th class="text-center">Since</th>
                        <th class="text-center">Created</th>
                        <th class="text-center">Details</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for p in object_list %}
                        <tr>
                            <td>{{ p.user }}</td>
                            <td>{{ p.process_type }}</td>
                            <td class="text-center">{{ p.created|timesince}}</td>
                            <td class="text-center">{{ p.created }}</td>
                            <td class="text-center">
                                {% if p.process_type == 'Q' %}
                                    <a href="/queries/{{ p.pk }}">details</a>
                                {% else %}
                                    <a href="/process/{{ p.pk }}">details</a>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}
{% block page_js%}
<script>
    $(document).ready(function() {
        InitializeTables();
    })
</script>
{% endblock %}
